#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int a[N][N], h = 1000, w = 0;
char s[N][N];
char c[10][10] = {
    "..+---+",
    "./   /|",
    "+---+ |",
    "|   | +",
    "|   |/.",
    "+---+.."   
};

void init() {
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            s[i][j] = '.';
}

void push(int x, int y) {
    h = min(h, x - 5);
    w = max(w, y + 6);
    x -= 5;
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 7; j++)
            if (c[i][j] != '.')
				s[x + i][y + j] = c[i][j];
}

void pull() {
    for (int i = h; i <= 1000; i++) {
        for (int j = 0; j <= w; j++)
            cout << s[i][j];
        cout << endl;
    }
}

int main() {
    init();
    int n, m;
    cin >> n >> m;
    int mx = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j], mx = max(mx, a[i][j]);
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= m; j++)
            for (int k = 1; k <= mx; k++) {
                int x = 1000 - 2 * (n - i - 1) - (k - 1) * 3;
                int y = 4 * j + (n - i - 1) * 2;
                if (a[i][j] >= k) push(x, y);
            }
    pull();
    return 0;
}
